import http from '@/http'

export default {
  /**
   * 仓储列表
   * @param {number} page  页码
   * @param {Function} success 回调
   */
  list(page, success) {
    http.get(
      "storage/list",
      {
        page: page
      },
      success
    );
  },

  areas(success) {
    http.get("area/all", {}, success);
  },
  /**
   * 仓储检索
   * @param {number} page 页码
   * @param {string} key 关键词
   * @param {Function} success 回调
   */
  search(page, key, success) {
    http.get(
      "storage/search",
      {
        page: page,
        key: key
      },
      success
    );
  },
  /**
   * 添加仓储
   * @param {Object} storage 仓储
   * @param {Function} success 回调
   */
  save(storage, success) {
    http.postBody("storage/add", storage, success);
  },
  /**
   * 更新仓储
   * @param {Object} storage 仓储
   * @param {Function} success 回调
   */
  update(storage, success) {
    http.postBody("storage/edit", storage, success);
  },
  /**
   * 删除仓储
   * @param {number} id 仓储id
   * @param {Function} success 回调
   */
  delete(id, success) {
    http.get("storage/delete/" + id, success);
  }
};
